# -*- coding: utf-8 -*-
from datetime import timedelta
from utils.operators.cluster_for_spark_sql_operator import SparkSqlOperator
from jms.dim.lmdm.dim_yl_sys_package_different_base import jms_dim__dim_yl_sys_package_different_base
from jms.dwd.tab.dwd_tab_reback_transfer_express_base import jms_dwd__dwd_tab_reback_transfer_express_base
from jms.dwd.oms.dwd_yl_oms_oms_order_incre_dt import jms_dwd__dwd_yl_oms_oms_order_incre_dt
from jms.dwd.tab.dwd_tab_barscan_bagging_base_dt import jms_dwd__dwd_tab_barscan_bagging_base_dt
from jms.dwd.tab.dwd_tab_electronic_package_list_base_dt import  jms_dwd__dwd_tab_electronic_package_list_base_dt
from jms.dim.dim_lmdm_sys_first_code import jms_dim__dim_lmdm_sys_first_code
from jms.dim.dim_lmdm_sys_network import jms_dim__dim_lmdm_sys_network

jms_dwd__dwd_tab_report_errorbagging_detail_dt = SparkSqlOperator(
    task_id='jms_dwd__dwd_tab_report_errorbagging_detail_dt',
    email=['payne.jiangchao@jtexpress.com','yl_bigdata@yl-scm.com'],
    name='jms_dwd__dwd_tab_report_errorbagging_detail_dt_{{ execution_date | date_add(1) | cst_ds }}',
    sql='jms/dwd/tab/dwd_tab_report_errorbagging_detail_dt/execute.sql',
    pool_slots=2,
    executor_cores=4,
    executor_memory='8G',
    driver_memory='4G',
    num_executors=20,  # spark.dynamicAllocation.enabled 为 True 时，num_executors 表示最少 Executor 数
    conf={'spark.dynamicAllocation.maxExecutors': 40,
          'spark.sql.sources.partitionOverwriteMode': 'dynamic',
          'spark.dynamicallocation.enabled': 'true',
          'spark.dynamicAllocation.cachedExecutorIdleTimeout': 120,
          'spark.shuffle.service.enabled': 'true',
          'spark.sql.shuffle.partitions': 200
          },
    yarn_queue='pro',
    execution_timeout=timedelta(minutes=40),
)

jms_dwd__dwd_tab_report_errorbagging_detail_dt << [jms_dwd__dwd_tab_barscan_bagging_base_dt
                                                ,jms_dwd__dwd_tab_electronic_package_list_base_dt
                                                ,jms_dwd__dwd_yl_oms_oms_order_incre_dt
                                                ,jms_dwd__dwd_tab_reback_transfer_express_base
                                                ,jms_dim__dim_lmdm_sys_first_code
                                                ,jms_dim__dim_yl_sys_package_different_base
                                                ,jms_dim__dim_lmdm_sys_network]
